package android.fwirk.obj;

import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.fwirk.R;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

public class CustomProgressDialog {
	TextView text;
	ImageView image1;
	ImageView image2;
	ImageView image3;
	ProgressBar pBar;
	AlertDialog dialog;
	Builder b;
	Context context;
	boolean isShowing;
	public CustomProgressDialog(Context context) {
		this.context=context;
		b=new Builder(context);
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View layout=new View(context);
		layout = inflater.inflate(R.layout.progress,(ViewGroup)layout.findViewById(R.id.layout_root));
		text = (TextView) layout.findViewById(R.id.text);
		image1 = (ImageView) layout.findViewById(R.id.image1);
		image2 = (ImageView) layout.findViewById(R.id.image2);
		image3 = (ImageView) layout.findViewById(R.id.image3);
		pBar= (ProgressBar) layout.findViewById(R.id.pBar);
		b.setView(layout);
		dialog=b.create();
	}
	
	public void setImage1(int resId) {
		image1.setImageResource(resId);
	}
	
	public void setImage1Visibility(int visibility) {
		image1.setVisibility(visibility);
	}
	
	public void setImage2(int resId) {
		image2.setImageResource(resId);
	}
	
	public void setImage2Visibility(int visibility) {
		image2.setVisibility(visibility);
	}
	
	public void setImage3(int resId) {
		image3.setImageResource(resId);
	}
	
	public void setImage3Visibility(int visibility) {
		image3.setVisibility(visibility);
	}
	
	public void setPBarVisibility(int visibility) {
		pBar.setVisibility(visibility);
	}
	
	public void setText(String t) {
		text.setText(t);
	}
	
	public void show() {
		isShowing=true;
		dialog.show();
	}
	
	public void hide() {
		isShowing=false;
		dialog.hide();
	}
	
	public AlertDialog getDialog() {
		return dialog;
	}
	
	public void dismiss() {
		isShowing=false;
		dialog.dismiss();
	}
	
	public boolean isShowing() {
		return isShowing;
	}
}
